<template>
    <div id="create_store">
        <el-dialog
        title="门店编辑"
        :visible.sync="dialogVisible"
        class=''
        top="10vh"
        :close-on-click-modal="false"
        :before-close="handleClose"
        >
            <div class="content_box">
                <el-form v-model= "formData" label-width="80px" label-position="left">
                    <el-form-item label="门店名称:">
                        <el-input size="small" v-model="formData.warehouseName" placeholder="请输入门店名称"></el-input>
                    </el-form-item>
                    <el-form-item label="门店类型:">
                        <el-select size="small" v-model="formData.isVirtual" placeholder="请选择门店类型" filterable>
                            <el-option
                                v-for="item in $Options.storeTypes"
                                :key="item.value"
                                :label="item.label"
                                :value="item.value">
                            </el-option>
                        </el-select>
                    </el-form-item>
                    <!-- <el-form-item label="选择省份:">
                        <el-select size="small" placeholder="请选择门店所在省份"></el-select>
                    </el-form-item>
                    <el-form-item label="选择城市:">
                        <el-select size="small" placeholder="请选择门店所在城市"></el-select>
                    </el-form-item>
                    <el-form-item label="选择区县:">
                        <el-select size="small" placeholder="请选择门店所在区、县"></el-select>
                    </el-form-item>
                    <el-form-item label="详细地址:">
                        <el-input type="textarea" rows="2" size="small" placeholder="请输入门店详细地址"></el-input>
                    </el-form-item>
                    <el-form-item label="门店经度:">
                        <el-input size="small" placeholder="请输入门店经度"></el-input>
                    </el-form-item>
                    <el-form-item label="门店纬度:">
                        <el-input size="small" placeholder="请输入门店纬度"></el-input>
                    </el-form-item> -->
                </el-form>
            </div>
            <span slot="footer" class="dialog-footer">
                <el-button size="small" @click="handleClose">取 消</el-button>
                <el-button size="small" type="primary" @click="handleSubmit">确 定</el-button>
            </span>
        </el-dialog>
    </div>
</template>
<script>
    export default {
        props: ['isShowCreate', 'type'],
        computed: {
            dialogVisible: {
                get() {
                    return this.isShowCreate;
                },
                set() {}
            }
        },
        data() {
            return {
                formData: {
                    isLocked: 1, // 仓库状态 0启用1禁用
                    isVirtual: 1, // 是否虚拟仓0否1是
                    outerWhId: '',
                    outerWhName: '',
                    outerWhNo: '',
                    storeNo: 'S00000001',
                    warehouseLevel: '1',
                    warehouseName: '',
                    warehouseType: '1'
                }
            }
        },
        mounted() {

        },
        methods: {
            handleClose() {
                this.$confirm('确认关闭？').then(_ => {
                    this.$emit('cancelShow', false)
                }).catch(_ => {});
            },
            handleSubmit() {
                let {isLocked, isVirtual, outerWhId, outerWhName, outerWhNo, storeNo, warehouseLevel, warehouseName, warehouseType} = this.formData
                let params= {
                    isLocked: isLocked,
                    isVirtual: isVirtual,
                    outerWhId: outerWhId,
                    outerWhName: outerWhName,
                    outerWhNo: outerWhNo,
                    storeNo: storeNo,
                    warehouseLevel: warehouseLevel,
                    warehouseName: warehouseName,
                    warehouseType: warehouseType
                }

                try {
                    this.$server.systemControlApi.createStore(params).then(res => {
                        this.$emit('cancelShow', false)
                    })
                } catch(err) {
                    this.$paramsError(err)
                }
            }
        }
    }
</script>